Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
unassertify
Advanced tools
Browserify transform for unassert: Encourages programming with assertions by providing tools to compile them away
Browserify transform for unassert: Encourages programming with assertions by providing tools to compile them away.
$ npm install --save-dev unassertify
$ $(npm bin)/browserify -t unassertify /path/to/src/target.js > /path/to/build/target.js
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var glob = require('glob'),
gulp.task('production_build', function() {
var files = glob.sync('./src/*.js');
var b = browserify({entries: files});
b.transform('unassertify');
return b.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
});
For given math.js
below,
'use strict';
var assert = require('assert');
function add (a, b) {
console.assert(typeof a === 'number');
assert(!isNaN(a));
assert.equal(typeof b, 'number');
assert.ok(!isNaN(b));
return a + b;
}
Run browserify
with -t unassertify
to transform file.
$ $(npm bin)/browserify -t unassertify /path/to/demo/math.js > /path/to/build/math.js
You will see assert calls disappear.
'use strict';
function add(a, b) {
return a + b;
}
Assertion expressions are removed when they match patterns below. In other words, unassertify removes assertion calls that are compatible with Node.js standard assert API (and console.assert
).
assert(value, [message])
assert.ok(value, [message])
assert.equal(actual, expected, [message])
assert.notEqual(actual, expected, [message])
assert.strictEqual(actual, expected, [message])
assert.notStrictEqual(actual, expected, [message])
assert.deepEqual(actual, expected, [message])
assert.notDeepEqual(actual, expected, [message])
assert.deepStrictEqual(actual, expected, [message])
assert.notDeepStrictEqual(actual, expected, [message])
assert.fail(actual, expected, message, operator)
assert.throws(block, [error], [message])
assert.doesNotThrow(block, [message])
assert.ifError(value)
console.assert(value, [message])
unassertify also removes assert variable declarations,
var assert = require("assert")
var assert = require("power-assert")
and assignments.
assert = require("assert")
assert = require("power-assert")
We support Node under maintenance. In other words, we stop supporting old Node version when their maintenance ends.
This means that any other environment is not supported.
NOTE: If unassertify works in any of the unsupported environments, it is purely coincidental and has no bearing on future compatibility. Use at your own risk.
Licensed under the MIT license.
2.1.1 (2018-04-19)
FAQs
Browserify transform for unassert: Encourages programming with assertions by providing tools to compile them away
We found that unassertify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.